/**
 * author      : dormi330
 * date        : 2018/6/24
 * project     : mybatis
 * description : TODO
 */

package com.deep.trade.infrastructure.mybatis.cart;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.deep.trade.domain.cart.CartSku;

import java.util.List;


@Mapper
public interface CartSkuMapper {

    int insert(@Param("eo") CartSku eo);

    int updateQty(
            // condition
            @Param("tenantCode") String tenantCode,
            @Param("cartSkuId") String cartSkuId,
            @Param("fromVersion") long fromVersion,

            // changed field
            @Param("quantity") int quantity,
            @Param("updatedBy") String updatedBy
    );

    int removeCartSku(
            // condition
            @Param("tenantCode") String tenantCode,
            @Param("cartSkuId") String cartSkuId,
            @Param("fromVersion") long fromVersion,

            // changed field
            @Param("updatedBy") String updatedBy
            // dr = 1
    );


    // 查询单个 cart
    CartSku queryByMeberAndSku(
            @Param("tenantCode") String tenantCode,
            @Param("memberId") String memberId,
            @Param("skuId") String skuId);

    List<CartSku> cartOfMember(
            @Param("tenantCode") String tenantCode,
            @Param("memberId") String memberId);
}
